<!DOCTYPE html>

<!--
  Google HTML5 slide template

  Authors: Luke Mahé (code)
           Marcin Wichary (code and design)
           
           Dominic Mazzoni (browser compatibility)
           Charles Chen (ChromeVox support)

  URL: http://code.google.com/p/dp-svn-tutorial/
-->

<html>
  <head>
    <title>SVN - Conflicts</title>

    <meta charset='utf-8'>
    <script
      src='../slides.js'></script>
  </head>
  
  <style>
    /* Your individual styles here, or just use inline styles if that’s
       what you want. */
    
    
  </style>

  <body style='display: none'>

    <section class='slides layout-regular template-default'>
      
      <!-- Your slides (<article>s) go here. Delete or comment out the
           slides below. -->
        
        
      
      <article class='biglogo'>
      </article>

      <article>
        <h1>
          SVN Tutorial
          <br>
          Resolving Conflicts
        </h1>
        <p>
          Uli Heller
          <br>
          September 07, 2011
        </p>
      </article>
      
      <article>
        <h3>
          Conflict 1
        </h3>
        <pre>
sample-1$ svn commit README.txt -m "Work on README.txt"
Adding         README.txt
svn: Commit failed (details follow):                  \
   svn: File already exists:                          \
   filesystem '/home/uli/svn/repo/sample.repo.svn/db',\
   transaction '14-f',                                \
   path '/trunk/README.txt'</pre>
        <ul class="build">
          <li>"File already exists"
          <li>transaction 14-f ... submitted in rev14?
          <li>path /trunk/README.txt ... submitted to svn trunk?
        </ul>
      </article>

      <article>
        <h3>
          Conflict 1 (2)
        </h3>
          <pre>
# Check status
sample-1$ svn status
A       README.txt

sample-1$ svn status -u
A       *        0   README.txt
        *       13   .
Status against revision:     14</pre>
        <ul class="build">
          <li>Not very helpful
          <li>* ... modified in svn repo
        </ul>
      </article>

      <article>
        <h3>
          Conflict 1 (3)
        </h3>
          <pre>
# svn update - get changes from repo
sample-1$ svn update
Conflict discovered in 'README.txt'.
Select: (p) postpone, (df) diff-full, (e) edit,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options: p
C    README.txt
Updated to revision 14.
Summary of conflicts:
  Text conflicts: 1</pre>
        <ul class="build">
          <li>Conflict in README.txt
          <li>No other conflicts
        </ul>
      </article>

      <article>
        <h3>
          Conflict 1 (4)
        </h3>
          <pre>
# Examine the status again
sample-1$ svn status
?       README.txt.mine
?       README.txt.r14
?       README.txt.r0
C       README.txt
# Examine history
sample-1$ svn log .
</pre>
        <ul class="build">
          <li>No additional info this time
          <li>Maybe good idea: <code>svn log README.txt</code>
          <li>Or even: <code>svn log .</code>
          <li>Examine the contents of the files (see next slide)
          <li>Create a "good" README.txt
        </ul>
      </article>

      <article class="smaller">
        <h3>
          Conflict 1 (5)
        </h3>
        <pre>
<<<<<<< .mine
README.txt, created by various developers (see below)

(c) copyright 2011 by Uli & Uwe

Developers:
I'm Uli. For SVN, I'm user #2.
My name is Uwe. I'm user #1.

Description:
This is our "hello world" program. It prints
a greeting and lots of loop messages. You can specify
the amount of loops and the delay per loop via command
line parameters.
=======
README.txt, created by various developers
>>>>>>> .r14
        </pre>
        <ul class="build">
          <li>After "P" (postpone), the file contains all versions
          <li>Separators are "<<<", "===", ">>>"
          <li>We added the many lines
          <li>Someone else added "README.txt, created by various developers"
        </ul>
      </article>

      <article>
        <h3>
          Conflict 1 (6)
        </h3>
          <pre>
# Tell svn we've fixed README.txt
sample-1$ svn resolved README.txt
Resolved conflicted state of 'README.txt'
# Query the status
sample-1$ svn status
M       README.txt
# Try to commit again
sample-1$ svn commit -m "More work on README.txt"
Sending        README.txt
Transmitting file data .
Committed revision 15.
</pre>
        <ul class="build">
          <li>Set conflict status to resolved
          <li>Double-check svn status
          <li>Doing a diff might be a good idea, too
          <li>Afterwards, do the commit
        </ul>
      </article>

      <article>
        <h3>
          Conflict 1 (7)
        </h3>
          <pre>
sample-1$ svn update
At revision 15.
sample-1$ svn status
sample-1$
</pre>
        <ul class="build">
          <li>Finally, do an update and check status
          <li>OK, we have a clean working copy
          <li>DONE!
        </ul>
      </article>

      <article>
        <h3>
          Conflict 1: Add - Add
        </h3>
        <pre>
sample-1$ svn commit README.txt -m "Work on README.txt"
Adding         README.txt
svn: Commit failed (details follow):                  \
   svn: File already exists:                          \
   filesystem '/home/uli/svn/repo/sample.repo.svn/db',\
   transaction '14-f',                                \
   path '/trunk/README.txt'</pre>
        <ul class="build">
          <li>"File already exists"
          <li>Someone else created the same file already
        </ul>
        <p class="build">
             <a href="../example-commands/conflict-add-add.txt">
                  <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-gnome-terminal.svg">
                     [link]
                     <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
             </a>
        </p>
      </article>

      <article>
        <h3>
          Conflict 2
        </h3>
        <pre>
sample-2$ svn commit -m "Added copyright"
Sending        README.txt
svn: Commit failed (details follow):
svn: File '/trunk/README.txt' is out of date
</pre>
        <ul class="build">
          <li>"File ... is out of date"
        </ul>
      </article>

      <article>
        <h3>
          Conflict 2 (2)
        </h3>
          <pre>
# Check status
sample-2$ svn status
M       README.txt

sample-2$ svn status -u
M       *       15   README.txt
Status against revision:     16</pre>
        <ul class="build">
          <li>Not very helpful
          <li>* ... modified in svn repo
        </ul>
      </article>

      <article>
        <h3>
          Conflict 2 (3)
        </h3>
          <pre>
sample-2$ svn update
Conflict discovered in 'README.txt'.
Select: (p) postpone, (df) diff-full, (e) edit,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options: p
C    README.txt
Updated to revision 16.
Summary of conflicts:
  Text conflicts: 1
sample-2$ </pre>
        <ul class="build">
          <li>Conflict in README.txt
          <li>No other conflicts
        </ul>
      </article>

      <article>
        <h3>
          Conflict 2 (4)
        </h3>
          <pre>
# Examine the status again
uli@uli-desktop:~/svn/sample$ svn status
?       README.txt.r15
?       README.txt.r16
?       README.txt.mine
C       README.txt
</pre>
        <ul class="build">
          <li>No additional info this time
          <li>Examine the contents of the files
          <li>Create a "good" README.txt
        </ul>
      </article>

      <article class="smaller">
        <h3>
          Conflict 2 (5)
        </h3>
          <pre>
<<<<<<< .mine
(c) copyright 2011 by Uli & Uwe

=======
Developers:
>>>>>>> .r16
I'm Uli. For SVN, I'm user #2.
My name is Uwe. I'm user #1.

Description:
This is our "hello world" program
</pre>
        <ul class="build">
          <li>After "P" (postpone), the file contains all versions
          <li>Separators are "<<<", "===", ">>>"
          <li>We added the copyright line
          <li>Someone else added "Developers:"
          <li>Some contents are unchanged
        </ul>
      </article>

      <article>
        <h3>
          Conflict 2 (6)
        </h3>
          <pre>
# Tell svn we've fixed README.txt
sample-2$ svn resolved README.txt
Resolved conflicted state of 'README.txt'
# Query the status
sample-2$ svn status
M       README.txt
# Try to commit again
# commit
sample-2$ svn commit -m "Added copyright"
Sending        README.txt
Transmitting file data .
Committed revision 17.
</pre>
        <ul class="build">
          <li>Set conflict status to resolved
          <li>Double-check svn status; maybe do a diff, too
          <li>Finally, do the commit
        </ul>
      </article>

      <article>
        <h3>
          Conflict 2 (7)
        </h3>
          <pre>
sample-2$ svn update
At revision 17.
sample-2$ svn status
sample-2$
</pre>
        <ul class="build">
          <li>Finally, do an update and check status
          <li>OK, we have a clean working copy
          <li>DONE!
        </ul>
      </article>

      <article>
        <h3>
          Conflict 2: Change - Change
        </h3>
        <pre>
sample-2$ svn commit -m "Added copyright"
Sending        README.txt
svn: Commit failed (details follow):
svn: File '/trunk/README.txt' is out of date</pre>
        <ul class="build">
          <li>"File ... is out of date"
          <li>Someone else modified the same file already
        </ul>
        <p class="build">
             <a href="../example-commands/conflict-change-change.txt">
                  <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-gnome-terminal.svg">
                     [link]
                     <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
             </a>
        </p>
      </article>

      <article>
        <h3>
          Conflict 3
        </h3>
        <pre>
sample-3$ svn commit -m "Don't list users on headline"
Sending        README.txt
svn: Commit failed (details follow):
svn: File 'README.txt' is out of date
svn: File not found: transaction '24-w', path '/trunk/README.txt'</pre>
        <ul class="build">
          <li>"File ... is out of date"
          <li>"File not found"
        </ul>
      </article>

      <article>
        <h3>
          Conflict 3 (2)
        </h3>
          <pre>
# svn update - get changes from repo
sample-3$ svn update
   C README.txt
At revision 24.
Summary of conflicts:
  Tree conflicts: 1</pre>
        <ul class="build">
          <li>Conflict in README.txt
          <li>Tree conflicts
          <li>Before, we had "Text conflicts"
        </ul>
      </article>

      <article>
        <h3>
          Conflict 3 (3)
        </h3>
          <pre>
# Examine the status again
sample-3$ svn status
A  +  C README.txt
      >   local edit, incoming delete upon update
</pre>
        <ul class="build">
          <li>We modified the file - "local edit"
          <li>In svn repo, it has been deleted - "incoming delete..."
          <li>Shall we create it again?
          <li>Do the contents go into another file now?
          <li>More investigation required!
              (svn log, talk)
        </ul>
      </article>

      <article class="smaller">
        <h3>
          Conflict 3 (4)
        </h3>
          <pre>
# If you want to keep it deleted, delete it with "rm README.txt" first
# We decide to create it again, so keep the file and mark it as resolved
sample-3$ svn resolved README.txt
Resolved conflicted state of 'README.txt'
# Check status
sample-3$ svn status
A       README.txt
# Commit
sample-3$ svn commit -m "Don't list users on headline - keeping README.txt"
Adding         README.txt
Transmitting file data .
Committed revision 25.</pre>
        <ul class="build">
          <li>Set conflict status to resolved
          <li>Double-check svn status; maybe do svn diff, too
          <li>Finally, do the commit
          <li>As expected, our changes lead to a file being <b>added</b>
        </ul>
      </article>

      <article>
        <h3>
          Conflict 3 (5)
        </h3>
          <pre>
sample-3$ svn update
At revision 25.
sample-3$ svn status
sample-3$
</pre>
        <ul class="build">
          <li>Finally, do an update and check status
          <li>OK, we have a clean working copy
          <li>DONE!
        </ul>
      </article>

      <article>
        <h3>
          Conflict 3: Delete - Change
        </h3>
        <pre>
sample-3$ svn commit -m "Don't list users on headline"
Sending        README.txt
svn: Commit failed (details follow):
svn: File 'README.txt' is out of date
svn: File not found: transaction '24-w', path '/trunk/README.txt'</pre>
        <ul class="build">
          <li>"File ... is out of date"
          <li>"File not found: ..."
          <li>Someone else deleted the file, we modified it
        </ul>
        <p class="build">
             <a href="../example-commands/conflict-delete-change.txt">
                  <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-gnome-terminal.svg">
                     [link]
                     <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
             </a>
        </p>
      </article>

      <article>
        <h3>
          Conflict 4
        </h3>
        <pre>
sample-4$ svn commit -m "Added short explanation to description"
Sending        README.txt
svn: Commit failed (details follow):
svn: File 'README.txt' is out of date
svn: File not found: transaction '18-l', path '/trunk/README.txt'</pre>
        <ul class="build">
          <li>"File ... is out of date"
          <li>"File not found"
        </ul>
      </article>

      <article>
        <h3>
          Conflict 4 (2)
        </h3>
          <pre>
# svn update - get changes from repo
sample-4$ svn update
   C README.txt
A    README
Updated to revision 18.
Summary of conflicts:
  Tree conflicts: 1</pre>
        <ul class="build">
          <li>Conflict in README.txt
          <li>Tree conflicts
          <li>What about README?
        </ul>
      </article>

      <article>
        <h3>
          Conflict 4 (3)
        </h3>
          <pre>
# Examine the status
sample-4$ svn status
A  +  C README.txt
      >   local edit, incoming delete upon update
M       README
</pre>
        <ul class="build">
          <li>We modified the file - "local edit"
          <li>In svn repo, it has been deleted - "incoming delete..."
          <li>README seems to be modified - why?
        </ul>
      </article>

      <article class="smaller">
        <h3>
          Conflict 4 (4)
        </h3>
          <pre>
sample-4$ rm README.txt
sample-4$ svn resolved README.txt
Resolved conflicted state of 'README.txt'
# Check status
sample-4$ svn status
M       README
# Commit
sample-4$ svn commit -m "Added short explanation to description"

Adding         README
Transmitting file data .
Committed revision 19.</pre>
        <ul class="build">
          <li>Verify: README contains all our changes
          <li>Delete README.txt
          <li>Set conflict status to resolved
          <li>Double-check svn status; maybe do svn diff, too
          <li>Finally, do the commit
        </ul>
      </article>

      <article>
        <h3>
          Conflict 4 (5)
        </h3>
          <pre>
sample-4$ svn update
At revision 19.
sample-4$ svn status
sample-4$
</pre>
        <ul class="build">
          <li>Finally, do an update and check status
          <li>OK, we have a clean working copy
          <li>DONE!
        </ul>
      </article>

      <article>
        <h3>
          Conflict 4: Move - Change
        </h3>
        <pre>
sample-4$ svn commit -m "Added short explanation to description"
Sending        README.txt
svn: Commit failed (details follow):
svn: File 'README.txt' is out of date
svn: File not found: transaction '18-l', path '/trunk/README.txt'</pre>
        <ul class="build">
          <li>"File ... is out of date"
          <li>"File not found: ..."
          <li>Someone else deleted the file, we modified it
          <li>"Move - Change" looks exactly like "Delete - Change"
        </ul>
        <p class="build">
             <a href="../example-commands/conflict-move-change.txt">
                  <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-gnome-terminal.svg">
                     [link]
                     <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
             </a>
        </p>
      </article>

      <article>
        <h3>
          Conflict 5
        </h3>
        <pre>
sample-5$ svn commit -m "Copied some lines from README.txt"
Sending        doc/hello.txt
svn: Commit failed (details follow):
svn: File 'hello.txt' is out of date
svn: File not found: transaction '27-11', path '/trunk/doc/hello.txt'
# Too bad...</pre>
        <ul class="build">
          <li>"File ... is out of date"
          <li>"File not found"
        </ul>
      </article>

      <article>
        <h3>
          Conflict 5 (2)
        </h3>
          <pre>
# Get the changes from svn
sample-5$ svn update
C doc
A    docs
A    docs/hello.txt
Updated to revision 27.
Summary of conflicts:
  Tree conflicts: 1
# A tree conflict, so a rename or delete took place</pre>
        <ul class="build">
          <li>Conflict in doc
          <li>Tree conflicts
          <li>What about docs? Something has been added...
        </ul>
      </article>

      <article>
        <h3>
          Conflict 5 (3)
        </h3>
          <pre>
# Show the status again...
sample-5$ svn status
A  +  C doc
      >   local edit, incoming delete upon update
M  +    doc/hello.txt
# doc has been deleted, we modified hello.txt
# but wait: docs has been added above - probablY a rename (move)?</pre>
        <ul class="build">
          <li>We modified the folder doc - "local edit"
          <li>In svn repo, it has been deleted - "incoming delete..."
          <li>doc/hello.txt is modified (our modifications)
        </ul>
      </article>

      <article class="smaller">
        <h3>
          Conflict 5 (4)
        </h3>
          <pre>
diff -r doc/hello.txt docs/hello.txt
2,6d1
< 
< This is our "hello world" program. It prints
< a greeting and lots of loop messages. You can specify
< the amount of loops and the delay per loop via command
< line parameters.
</pre>
        <ul class="build">
          <li>Make a DIFF between what we modified an what's been added
              (see above)
          <li>Copy our version to the new folder: <code>cp doc/hello.txt docs/.</code>
          <li>Verify the output of <code>svn diff</code>
          <li>Remove the old folder: <code>svn rm doc</code> (*)
          <li>Resolve the conflict: <code>svn resolved doc</code>
          <li>Do a commit: <code>svn commit -m ...</code>
        </ul>
      </article>

      <article>
        <h3>
          Conflict 5 (5)
        </h3>
          <pre>
sample-5$ svn update
At revision 28.
sample-5$ svn status
sample-5$
</pre>
        <ul class="build">
          <li>Finally, do an update and check status
          <li>OK, we have a clean working copy
          <li>DONE!
        </ul>
      </article>

      <article>
        <h3>
          Conflict 5: Folder Move - Change
        </h3>
        <pre>
sample-5$ svn commit -m "Copied some lines from README.txt"
Sending        doc/hello.txt
svn: Commit failed (details follow):
svn: File 'hello.txt' is out of date
svn: File not found: transaction '27-11', path '/trunk/doc/hello.txt'</pre>
        <ul class="build">
          <li>"File ... is out of date"
          <li>"File not found: ..."
          <li>"Folder Move - Change" looks exactly like "Move - Change"
              and "Delete - Change"
        </ul>
        <p class="build">
             <a href="../example-commands/conflict-folder-move-change.txt">
                  <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-gnome-terminal.svg">
                     [link]
                     <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
             </a>
        </p>
      </article>

      <article>
        <h3>
          Conflict 6
        </h3>
        <pre>
sample-6$ svn commit -m "Added remark about new features"
Sending        docs/hello.txt
svn: Commit failed (details follow):
svn: File 'hello.txt' is out of date
svn: File not found: transaction '29-14', path '/trunk/docs/hello.txt'</pre>
        <ul class="build">
          <li>"File ... is out of date"
          <li>"File not found"
        </ul>
      </article>

      <article>
        <h3>
          Conflict 6 (2)
        </h3>
          <pre>
# Get the changes from svn
sample-6$ svn update
   C docs
At revision 29.
Summary of conflicts:
  Tree conflicts: 1</pre>
        <ul class="build">
          <li>Conflict in docs
          <li>Tree conflicts
        </ul>
      </article>

      <article>
        <h3>
          Conflict 6 (3)
        </h3>
          <pre>
# Check the status
sample-6$ svn status
A  +  C docs
      >   local edit, incoming delete upon update
M  +    docs/hello.txt
</pre>
        <ul class="build">
          <li>We modified the folder docs - "local edit"
          <li>In svn repo, it has been deleted - "incoming delete..."
          <li>docs/hello.txt is modified (our modifications)
        </ul>
      </article>

      <article class="smaller">
        <h3>
          Conflict 6 (4)
        </h3>
          <pre>
# Mark it resolved...
sample-6$ svn resolved docs
Resolved conflicted state of 'docs'

# Check status
sample-6$ svn status
A  +    docs
M  +    docs/hello.txt
</pre>
        <ul class="build">
          <li>We assume: The folder has been deleted by accident
          <li>So: We don't delete anything
          <li>The folder will be added again
          <li><code>svn commit -m "Added remark about new features - keeping docs"</code>
        </ul>
      </article>

      <article>
        <h3>
          Conflict 6 (5)
        </h3>
          <pre>
sample-6$ svn update
At revision 30.
sample-6$ svn status
sample-6$
</pre>
        <ul class="build">
          <li>Finally, do an update and check status
          <li>OK, we have a clean working copy
          <li>DONE!
        </ul>
      </article>

      <article>
        <h3>
          Conflict 6: Folder Delete - Change
        </h3>
        <pre>
sample-6$ svn commit -m "Added remark about new features"
Sending        docs/hello.txt
svn: Commit failed (details follow):
svn: File 'hello.txt' is out of date
svn: File not found: transaction '29-14', path '/trunk/docs/hello.txt'</pre>
        <ul class="build">
          <li>"File ... is out of date"
          <li>"File not found: ..."
          <li>"Folder Delete - Change" looks exactly like "Folder Move - Change", "Move - Change"
              and "Delete - Change"
        </ul>
        <p class="build">
             <a href="../example-commands/conflict-folder-delete-change.txt">
                  <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-gnome-terminal.svg">
                     [link]
                     <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
             </a>
        </p>
      </article>

      <article>
        <h3>
          Conflicts - Summary
        </h3>
        <ul class="build">
          <li>You get aware of them on commit and/or update
          <li>They are annoying (extra work)
          <li>Sometimes, they are hard to analyze
          <li>They are even harder to analyze if many files are involved
          <li><code>svn status</code> sometimes helps
          <li><code>svn log</code> often helps
          <li>Sometimes you have to talk to others
          <li>Usually, you must <b>not</b> ignore conflicts
          <li>They tend to happen more often once you use branches
        </ul>
      </article>

      <article>
        <h1>
          Thank You!
        </h1>
      </article>
    </section>

  </body>
</html>
